package uk.ac.aber.Blockmation.Actions;

import javax.swing.ImageIcon;

/**
 * Returns imageIcon from a file - used to get the absolute path name to a file.
 * This algorithm/method has been slightly altered from an example on the Swing
 * GUI tutorials from Sun - http://java.sun.com/docs/books/tutorial/uiswing/
 * 
 * @author alex
 */
public class CreateImageIcon {

    public ImageIcon create(String path) {
        
        java.net.URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
        
    }
}
